package com.wushe.firstexample;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @description:
 * @author: WuShe
 * @date: 2019/11/28 13:58
 * @version: 1.0.0
 * @modified By:
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    /**
     * @description 初始化器，回调的方法
     * @param socketChannel
     * @return void
     */
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();//管道

        pipeline.addLast("httpServerCodec", new HttpServerCodec());//使用netty进行http请求
        pipeline.addLast("myHttpServerHandler", new TestHttpServerHandler());
    }
}
